07. Debugging: Strategy Recap

Debugging Strategy Recap

We went over 5 debugging strategies in this lesson.

  1. Examine error messages when programs crash

    The last line of Python Tracebacks will tell you what went wrong. Reading backwards from there will tell you more about where the problem occurred.

  2. Work from example code

    If your modified code doesn't work, comment it out and do step-by-step modifications to the example code until it does what you want.

  3. Make sure examples work

    Just because you find example code doesn't mean it will work in your system. Check the example code you're using to make sure it behaves the way you expect.

  4. Check (print) intermediate results

    When your code doesn't crash, but doesn't behave as expected, add print statements to your program to see where in the code things stop behaving correctly.

  5. Keep and compare old versions

    When you have a working version of your code, save it before you add to the code. This will give you something to go back to if you introduce too many new bugs.

Debugging is Awesome!

Debugging is Awesome!